package com.cn.admin.handle;

import com.cn.admin.exception.CustomException;
import com.cn.admin.vo.ResponseObject;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 异常处理类
 * controller层异常无法捕获处理，需要自己处理
 * Created by jt on 2018/8/27.
 */
@RestControllerAdvice
public class DefaultExceptionHandler {

    /**
     * 处理所有自定义异常
     * @param e
     * @return
     */
    @ExceptionHandler(CustomException.class)
    public ResponseObject handleCustomException(CustomException e){
        return e.getResponseObject();
    }
}
